package com.gupao.vip.Indicator;

import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.stereotype.Component;

/**
 * 自定义健康端点
 * <p>功能更加强大一点，DataSourceHealthIndicator / RedisHealthIndicator 都是这种写法</p>
 * Created by 17082655 on 2019/1/6.
 */
@Component("my2")
public class MyAbstractHealthIndicator extends AbstractHealthIndicator {
	private static final String VERSION = "v1.0.0";
	@Override
	protected void doHealthCheck(Health.Builder builder) throws Exception {
		int code = check();
		if (code != 0) {
			builder.down().withDetail("code", code).withDetail("version", VERSION).build();
		}
		builder.withDetail("code", code)
				.withDetail("version", VERSION).up().build();
	}
	private int check() {
		return 0;
	}
}
